package com.vnp.cooking.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.vnp.cooking.R;
import com.vnp.cooking.bean.ObjDetailTopic;
import com.vnp.cooking.bean.ObjSlidingMenu;

public class ListDetailAdapter extends ArrayAdapter<ObjDetailTopic>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	Context context;
	ArrayList<ObjDetailTopic> objDetailTopics;
	int resource;
	TextView txtObjDetailTopic;
	ImageView imgObjDetailTopic;
	
	public ListDetailAdapter(Context context, ArrayList<ObjDetailTopic> objDetailTopics) {
		super(context,R.layout.list_item_detail_topic, objDetailTopics);
		this.context = context;
		this.objDetailTopics = objDetailTopics; 
	}


	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			 LayoutInflater inflater = LayoutInflater.from(getContext());
			 convertView = inflater.inflate(R.layout.list_item_detail_topic, parent, false);
			 
			 txtObjDetailTopic = (TextView) convertView.findViewById(R.id.txt_detail_topic);
			 imgObjDetailTopic = (ImageView) convertView.findViewById(R.id.img_detail_topic);
			 
		}
		
		txtObjDetailTopic.setText(objDetailTopics.get(position).getTxtTopic());
		imgObjDetailTopic.setImageResource(objDetailTopics.get(position).getImgTopic());
		
		
		return convertView;
	}

}
